Token Formatting--Date and Time
You can format tokens to automatically convert dates and times entered into them into specified formats. A standard format string is a single letter that represents a format that your data will automatically be converted to. A custom format string is a group of symbols that indicate the exact format for the information. Standard format strings are just shortcuts for frequently used formats that could also be achieved with custom format strings. You can type these specifiers directly in the tokens or use the Token Editor to insert the specifier and test the formatted token.
Note: The regional settings such as date and currency are Windows regional settings found in the Control Panel for the Workflow Server computer.
Note: A single-character date/time format string will be interpreted as a standard date/time format string. Multiple-character date/time format strings will be interpreted as custom strings. To use a single-character custom string, include a % sign before the character or a space before or after it.
Standard Date and Time Format Strings
Standard date and format strings can be inserted into Workflow tokens to format the values to match patterns determined by the regional settings of the computer where the Workflow Server is installed. View the regional settings in the control panel of the Workflow Server computer to determine how these strings will format your tokens.
Example: Formatting regional settings:
Formatted token: | %(DateTime#"g"#) |
Input: | January 23, 2009, 0:00 |
Result: | 1/23/2009 12:00 AM (English - United States) |
23/01/2009 00:00 (French - France) | |
2009-01-23 00:00 (French - Canada) |
Specifier | Type | Function |
---|---|---|
d | Short date pattern | Formats date and date/time strings to the short date pattern defined in the Workflow Server computer's regional settings. |
D | Long date pattern | Formats date and date/time strings to the long date pattern defined in the Workflow Server computer's regional settings. |
t | Short time pattern | Formats date/time and time strings to the short time pattern defined by the Workflow Server computer's settings (hours and minutes). |
T | Long time pattern | Formats date/time and time strings to the long time pattern defined by the Workflow Server computer's settings (hours, minutes, and seconds). |
f | Full date/time pattern (short time) | Represents a combination of the long date (D) and short time (t) patterns, separated by a space. |
F | Full date/time pattern (long time) | Represents a combination of the long date (D) and long time (T) patterns, separated by a space. |
g | General date/time pattern (short time) | Represents a combination of the short date (d) and short time (t) patterns, separated by a space. |
G | General date/time pattern (long time) | Represents a combination of the short date (d) and long time (T) patterns, separated by a space. |
M | Month day pattern | Displays the month and day according to the Workflow Server computer's regional settings. |
Y or y | Year month pattern | Displays the year and month according to the Workflow Server computer's regional settings. |
u | Universal sortable pattern | Always formats to a pattern with a four-digit year first, followed by 2-digit month, day, year, hour, minute, and seconds. |
Custom Date and Time Format Strings
You can also create custom strings to format dates and times to any combination of date and time formats. A popular use for this is to use dates extracted from your documents to create document names or folder paths according to a standardized system.
Example: Margarita wants to organize her documents into folders labeled with the last two digits of the year and the abbreviation for the month. She formats a token that contains the date accordingly and uses the Rename Entry activity to name her folders.
Formatted Token: | %(Date#"yy-MMM"#) |
Input: | January 23, 2009 |
Result: | 09-Jan (English-United States) |
09-jan (Portuguese-Brazil) | |
09-ene (Spanish-Spain) |
Note: On most Windows computers, the system clock's resolution is approximately 10-15 milliseconds, so while seconds can be formatted to additional digits, they may not be accurate beyond that threshold.
Specifier | Type | Function |
---|---|---|
/ | Date separator | Used to differentiate years, months, and days. May be replaced by the date separator defined in the Workflow Server computer's regional settings, if that is different. |
: | Time separator | Used to differentiate hours, minutes, and seconds. May be replaced by the time separator defined in the Workflow Server computer's regional settings, if that is different. |
" or ' | Quoted string indicator | The value in between quotation marks (excepting the quotation marks around the entire expression) will be interpreted literally, not as a formatting specifier. |
% | Single custom format specifier indicator | When using a single custom format specifier, precede it with the % symbol. For example, to use M for the month section of a custom formatting string, write %M. |
\ | Escape character | A character preceded by the backslash character (\) will be interpreted literally, not as a formatting specifier. |
d | Day: 1-31 | Represents the day of the month as a number from 1 through 31. A single-digit day will be formatted without a leading zero. |
dd | Day: 01-31 | Represents the day of the month as a number from 01-31. A single-digit day will be formatted with a leading zero. |
ddd | Abbreviated day of the week | Represents the abbreviated name of the day of the week as defined in the Workflow Server computer's regional settings. |
dddd (etc.) | Full day of the week | Represents the full name of the day of the week as defined in the Workflow Server computer's regional settings. |
M | Month: 1-12 | Represents the month as a number from 1 through 12. A single-digit month will be formatted without a leading zero. |
MM | Month: 01-12 | Represents the month as a number from 01 through 12. A single-digit month will be formatted with a leading zero. |
MMM | Abbreviated month | Represents the abbreviated name of the month according to the Workflow Server computer's regional settings. |
MMMM | Full month | Represents the full name of the month according to the Workflow Server computer's regional settings. |
y | Year: 1-2 digits | Formats the year to a one or two-digit number. If the year has more than two digits, the lowest order two will be displayed. If the first of the two digits is a zero, the number will be displayed without the leading zero. |
yy | Year: 2 digits | Formats the year to a two-digit number. If the year has more than two digits, the lowest order two will be displayed. If the first of the two digits is a zero, the number will be displayed with a leading zero. |
yyy | Year: 3 or more digits | Formats the year to a number with three or more digits. If the year has fewer than three digits, it will be formatted with leading zeroes. If it has more than three, they will all be displayed. |
yyyy | Year: 4 digits | Formats the year to a four-digit number. If the year has fewer than four digits, it will be formatted with leading zeroes. If it has more than four digits, only the four lowest-order digits will be displayed (except in the case of the Thai Buddhist calendar, which may display five digits). |
yyyyy (etc.) | Year: 5 or more digits | Formats the year to the number of digits equal to the number of years. If the year has fewer digits than specified, it will be padded with leading zeroes. |
g, gg, etc. | Era | Represents the period or era, for example, A.D. This specifier will be ignored if the date to be formatted does not have a period or era association. |
h | Hour: 1-12 | Represents the hour as a number from 1 through 12. If the hour is a single digit, it will be formatted without a leading zero. |
hh | Hour: 01-12 | Represents the hour as a number from 01 through 12. If the hour is a single digit, a leading zero will be appended. |
H | Hour: 0-23 | Represents the hour as a number from 0 through 23. If the hour is a single digit, it will be formatted without a leading zero. |
HH | Hour: 00-23 | Represents the hour as a number from 00 through 23. If the hour is a single digit, a leading zero will be appended. |
m | Minutes: 0-59 | Represents the number of whole minutes since the last hour. If the number is a single digit, it will be formatted without a leading zero. |
mm | Minutes: 00-59 | Represents the number of whole minutes since the last hour. A single digit will be appended with a leading zero. |
s | Seconds: 0-59 | Represents the number of whole seconds since the last minute. If the number is a single digit, it will be formatted without a leading zero. |
ss | Seconds: 00-59 | Represents the number of whole seconds since the last minute. A single digit will be appended with a leading zero. |
f, ff, fff, etc. | Fractions of a second | Each f represents a digit of the second's fraction to display. A zero will be displayed if the digit is zero. |
F, FF, FFF, etc. | Fractions of a second | Each F represents a digit of the second's fraction to display. Nothing will be displayed if the digit is zero and there is no other value after it. |
t | First character of the AM/PM designator | The first character of the designator for whether the time is before or after noon, as determined by the Workflow Server computer's regional settings |
tt | AM/PM designator | The designator for whether the time is before or after noon, as determined by the Workflow Server computer's regional settings |
To learn more about .NET date and time formatting, see the Microsoft Developers' Network (MSDN) site at
https://msdn.microsoft.com/en-us/library/az4se3k1.aspx
and